<%-- 
    Document   : account
    Created on : Nov 23, 2009, 7:19:17 PM
    Author     : Jeremy
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="jhu.profiteer.data.Account" %>
<%@ page import="jhu.profiteer.data.AccountJpaController" %>

<%@ include file="/WEB-INF/jspf/admin/auth.jspf" %>
<html>
  <%
    String pageTitle = "Administration Homepage - Account";
    String cssFile = "/profiteer-game/css/profiteer.css";
    String param = request.getParameter("accountId");
    Account a = null;

    if((null != param) && (!param.isEmpty()))
    {
      AccountJpaController jc = new AccountJpaController();
      a = jc.findAccount(Long.parseLong(param));
    }
  %>
  <%@ include file="/WEB-INF/jspf/admin/header.jspf" %>
  <body>
    <%@ include file="/WEB-INF/jspf/title.jspf" %>
    <div class="contentArea Body">
      <div class="pagetitle">Administration</div>
      <div class="pagebody">
        <table>
          <tr>
            <td id="menu"><%@ include file="/WEB-INF/jspf/admin/sidebar.jspf" %></td>
            <td>
              <div class="divround">
                <%@ include file="/WEB-INF/jspf/admin/notice.jspf" %>
                <form action="processAccount" method="post">
                  <% if (null != a) { %><input type="hidden" name="accountId" value="<%= a.getId() %>" /><% } %>
                  <table>
                    <tr>
                      <td>Name:</td>
                      <td><input type="text" name="name" <% if(null != a) { %> value="<%= a.getName() %>" <% } %>/></td>
                    </tr>
                    <tr>
                      <td>Administrator:</td>
                      <td>
                        <select name="administrator">
                          <option value="true" <% if((null != a) && a.isAdministrator()) { %> selected="selected" <% } %>>True</option>
                          <option value="false" <% if((null != a) && !a.isAdministrator()) { %> selected="selected" <% } %>>False</option>
                        </select>
                      </td>
                    </tr>
                    <%
                      if(null != a)
                      {
                    %>
                    <tr>
                      <td>Damaged:</td>
                      <td>
                        <select name="damaged">
                          <option value="true" <% if((null != a) && a.isDamaged()) { %> selected="selected" <% } %>>True</option>
                          <option value="false" <% if((null == a) || !a.isDamaged()) { %> selected="selected" <% } %>>False</option>
                        </select>
                      </td>
                    </tr>
                    <%
                      }
                      else
                      {
                    %>
                    <tr>
                      <td>Password:</td>
                      <td><input type="password" name="password" /></td>
                    </tr>
                    <% } %>
                    <tr>
                      <td>Email Address:</td>
                      <td><input type="text" name="email" <% if(null != a) { %> value="<%= a.getEmailAddress() %>" <% } %>/></td>
                    </tr>
                  </table>
                  <input type="submit" name="submit" <% if(null == a) { %> value="Create" <% } else { %> value="Update" <% } %> />
                </form>
              </div>
            </td>
          </tr>
        </table>
      </div>
    </div>
    <%@ include file="/WEB-INF/jspf/footer.jspf" %>
  </body>
</html>
